package com.kaibes.platform.member;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.kaibes.module.user.UserService;
import com.kaibes.orm.core.listener.InsertListener;
import com.kaibes.orm.curd.Insert;
import com.kaibes.orm.curd.InsertBuilder;
import com.kaibes.orm.spring.OrmListener;
import com.kaibes.platform.member.db.Member;
import com.kaibes.platform.member.db.MemberService;

@OrmListener(service = UserService.class)
public class UserInsertListener4Member implements InsertListener<Integer> {
    
    @Autowired
    private MemberService memberService;

    @Override
    public void afterInsert(Insert insert, List<Integer> ids) throws Exception {
        Member member = new Member();
        member.setUserId(ids.get(0).intValue());
        member.setExperience(0);
        memberService.getMapper().insert(InsertBuilder.newBuilder().addData(member).build());
    }
}
